<template>
  <div>
    <!-- 面包屑导航 -->
     <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/Home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图 -->
    <el-card>
      <el-table :data="userPowersList" stripe  border>
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="powerName" label="权限名称"></el-table-column>
        <el-table-column  prop="path" label="权限路径"></el-table-column>
        <el-table-column  prop="powersLevel" label="权限等级">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.Level == 1">一级权限</el-tag>
            <el-tag type="success" v-else-if="scope.row.Level == 2">二级权限</el-tag>
            <el-tag type="warning" v-else>三级权限</el-tag>
          </template>
        </el-table-column>
        </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userPowersList: [
        {
          powerName: "用户添加",
          path: "/users",
          Level: 1
        },
        {
          powerName: "用户删除",
          path: "/users",
          Level: 1
        },
        {
          powerName: "分配角色",
          path: "/users",
          Level: 1
        },
        {
          powerName: "商品添加",
          path: "/addShops",
          Level: 2
        },
        {
          powerName: "商品删除",
          path: "/dels",
          Level: 2
        },
        {
          powerName: "订单核查",
          path: "/checks",
          Level: 3
        }
      ]
    }
  },
  created() {
    this.getUserPowers()
  },
  methods: {
    async getUserPowers() {
      try{
        const {data: res} = await this.$http.get('powers', this.userPowersList)
        this.userPowersList = res.data
      }
      catch(error) {
        this.$message.error('获取权限列表失败')
        console.log(error);
      }
    }
  }
}
</script>

<style lang="less" scoped>

</style>